@extends("admin.base")
    @section("content")
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            信息输出表
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">主页商品类别信息管理</a></li>
            <li class="active">列表</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 主页商品类别信息管理</h3><br/>
				<button class="btn btn-primary" onclick="loadAdd()">添加分类</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    <tr>
                      <th style="width:80px">类别id号</th>
                      <th>类别名称</th>
                      <th>父类别id号</th>
                      <th>路径</th>
					  <th>导航图片</th>
                      <th style="width: 200px">操作</th>
                    </tr>
                    @foreach($list as $v)
                    <tr>
                      <td>{{$v->id}}</td>
                      <td>{{$v->name}}</td>
                      <td>{{$v->pid}}</td>
                      <td>{{$v->pidstr}}</td>
						@if($v->pid==0)
							<td>
								<img width='200' src="{{asset('img/home')}}/{{$v->pic}}" width='150' id='imgShow' alt='缩略图'/>
							</td>
						@else
							<td></td>
						@endif
                      <td>
						<button onclick="doDel({{$v->id}})" class="btn btn-xs btn-danger">删除</button>
						<form action="{{url('admin/type')}}/{{$v->id}}" method="post" style="display:inline">
							<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
							<input type="hidden" name="_method" value="GET">
							<button type="submit" class="btn btn-xs btn-primary">修改</button>
						</form>
					  </td>
                    </tr>
                    @endforeach
                  
                   
                  </table>
                </div><!-- /.box-body -->
				 
              </div><!-- /.box -->

              
              
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
        </form>
    @endsection
    
    
    @section("myscript")
	<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveType()" class="btn btn-primary">保存</button>
          </div>
        </div>
      </div>
    </div>
	<script type="text/javascript">
		function doDel(id){
			if(confirm('确定要删除吗？')){
				$("#mydeleteform").attr("action","{{url('admin/type')}}/"+id).submit(); 
				}
			}
		//加载添加表单
		 function loadAdd(){
            $("#exampleModalLabel").html("添加商品类别");
            $("#exampleModal").modal("show");
            
            $.ajax({
                url:"{{URL('admin/type/create')}}",
                type:"get",
                dataType:"html",
                async:true,
                success:function(data){
                  $("#exampleModal .modal-body").html(data);   
                },
             });
            
        }
		
		//保存类别信息
		function saveType(){
			$("#myaddform").submit();
		}
	</script>
    @endsection